﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Security;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;

namespace game518_daily_service
{
    class Program
    {
        static void Main(string[] args)
        {
            calc();
        }

        public static void calc()
        {
            string connStr = System.Configuration.ConfigurationManager.AppSettings["db"];
            SqlConnection conn = new SqlConnection(connStr);
            Console.WriteLine("计算...");
            int i = 0;
            try
            {
                conn.Open();
                //sp_stat_agency(conn);
                sp_stat_money_agency_day(conn);
                sp_stat_money_day(conn);
            }
            finally
            {
                conn.Close();
            }
            Console.WriteLine("计算结束");
        }

        private static void sp_stat_agency(SqlConnection conn)
        {
            SqlCommand comm = new SqlCommand("sp_stat_agency", conn);
            comm.CommandType = CommandType.StoredProcedure;
            comm.Parameters.Add(new SqlParameter("@stattime", SqlDbType.DateTime, 4));
            comm.Parameters["@stattime"].Value = DateTime.Now;
            try
            {
                comm.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                LogHelper.WriteLog(e);
            }
            finally
            {

            }
        }

        private static void sp_stat_money_agency_day(SqlConnection conn)
        {
            SqlCommand comm = new SqlCommand("sp_stat_money_agency_day", conn);
            comm.CommandType = CommandType.StoredProcedure;
            try
            {
                comm.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                LogHelper.WriteLog(e);
            }
            finally
            {

            }
        }

        private static void sp_stat_money_day(SqlConnection conn)
        {
            SqlCommand comm = new SqlCommand("sp_stat_money_day", conn);
            comm.CommandType = CommandType.StoredProcedure;
            comm.Parameters.Add(new SqlParameter("@stattime", SqlDbType.DateTime, 4));
            comm.Parameters["@stattime"].Value = DateTime.Now;
            try
            {
                comm.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                LogHelper.WriteLog(e);
            }
            finally
            {

            }
        }
    }
}
